package com.urick.spi.dubbo;

import com.urick.spi.dubbo.ext.IExt;
import com.urick.spi.dubbo.ext.IExtResult;
import com.urick.spi.dubbo.ext.base.BaseExtWrapper;
import com.urick.spi.dubbo.ext.base.DefExtWrapper;
import org.junit.Assert;
import org.junit.Test;

/**
 * Design Theories:
 * <a href=""></a>
 *
 * @author uRick 2021/12/13 11:20
 * Email: rickwork@163.com
 * Wechat: yy3076815642
 * QQ: 3076815642
 * @since 1.0
 */
public class BasicTester {
    @Test
    public void baseExtTester() {
        IExt extension = ExtensionLoader.getExtensionLoader(IExt.class).getExtension("baseExt");
        Assert.assertEquals(Boolean.TRUE, IExtResult.checkOk(extension.exe()));
    }

    @Test
    public void baseDefExtTester() {
        IExt extension = ExtensionLoader.getExtensionLoader(IExt.class).getDefaultExtension();
        Assert.assertEquals(Boolean.TRUE, IExtResult.checkOkAndMsg(extension.exe(), "defExt"));
    }

    @Test
    public void baseWrapperTester() {
        IExt defExt = ExtensionLoader.getExtensionLoader(IExt.class).getDefaultExtension();
        defExt.exe();
        Assert.assertTrue((defExt instanceof DefExtWrapper));
    }

    @Test
    public void defWrapperTester() {
        IExt baseExt = ExtensionLoader.getExtensionLoader(IExt.class).getExtension("baseExt");
        baseExt.exe();
        Assert.assertTrue(baseExt instanceof BaseExtWrapper);
    }
}
